package com.lzp.exception;

import com.lzp.utils.ServerResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

/**
 * 自定义异常助手类,使错误信息更加人性化的反馈给用户
 *
 * @author dtyy
 * @date 2020/10/15
 */
@RestControllerAdvice
public class CustomExceptionHandler {

    // MaxUploadSizeExceededException
    @ExceptionHandler(MaxUploadSizeExceededException.class)
    public ServerResponse handleMaxUploadFile(MaxUploadSizeExceededException exception) {
        return ServerResponse.createByErrorMsg("文件大小不能超过200KB");
    }

}
